(function () {

    foo()
    console.log(x)
    // console.log(y)

    function foo(name = "周杰伦") {
        console.log(`i am foo，you are ${name}`)
        return 'function foo'
    }

    var bar = function () {
        console.log('i am bar ')
        return 'function bar'
    }

    // var x = 1
    var x; //会提升到最前面
    x = 1
    // let y = 2

    //形参，定义函数过程中的参数
    //实参，调用函数过程中阿参数
    //参数默认值
    //arguments 对象 获取函数的实参
    let name = "刘磊"
    foo()

    // function sum(a,b){
    //     return a+b
    // }
    // function sum(a,b,c){
    //     return a+b+c
    // }

    function sum() {
        let res = 0
        for (arg of arguments) {
            res += arg
        }
        return res
    }

    function sum1(...args) {
        let res = 0
        console.log(args)
        for (arg of args) {
            res += arg
        }
        return res
    }

    // function start(){
    //     console.log('让页面动起来')
    // }

    // start()
    let z = 1;
    // (function start(){
    //     console.log('让页面动起来')
    // })()

    function say() {
        console.log(`hello i am ${name}`)
    }
    say()
    
    //say("王大锤")
    // (function say(name){
    //     console.log(`hello i am ${name}`)
    // })('王大锤')

})()